<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- 注意: 部署时，将 "development.js" 替换为 "production.min.js"。-->
    <!-- jsx特点：多个标签最外层（根）只能有一个标签 -->
    <script
      src="https://unpkg.com/react@16/umd/react.development.js"
      crossorigin
    ></script>
    <script
      src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
      crossorigin
    ></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

    <script type="text/babel">
      // 封装APP组件
      class App extends React.Component {
        constructor(props) {
          super(props);
          this.state = {
            // 可以在{}显示
            name: "why", //String
            age: 18,
            names: ["abc", "cab", "bac"],
            // 在{}不能显示（忽略）
            test1: null,
            test2: undefined,
            test3: false,
            falg: true,
            // 3、对象不能做jsx的子类
            friend:{
              name:'kobe',
              age:40
            }
          };
        }
        render() {
          return (
            <div>
              <h2>{this.state.name}</h2>
              <h2>{this.state.age}</h2>
              <h2>{this.state.names}</h2>
              <h2>{this.state.test1 + ""}</h2>
              <h2>{this.state.test2 + ""}</h2>
              <h2>{this.state.test3.toString()}</h2>
              <h2>{this.state.falg ? "你好" : null}</h2>
              <h2>{this.state.falg && "八嘎"}</h2>
              <h2>{this.state.friend.name}</h2>

            </div>
          );
        }
      }
      // 渲染组件
      ReactDOM.render(<App />, document.getElementById("app"));
    </script>
  </body>
</html>
